{{template "admin/header.html"}}
<title>更新站点信息 - GPRESS</title>
{{template "admin/bodystart.html"}}



<section class="section">
	<div class="container">
		<div class="table-content">
			<div class="column">
				<form id="gpress-form" action="{{basePath}}admin/{{.UrlPathParam}}/update" method="POST">
					<input type="hidden" name="id" id="id" value="{{.Data.Id}}">
					<ul class="save-ul">
						<li>
							<div class="left">
								ID
							</div>
							<div class="right">
								<input type="hidden" name="id" id="id" value="{{.Data.Id}}" />
								<input class="input is-small" type="text" disabled value="{{.Data.Id}}">
							</div>
						</li>
						<li>
							<div class="left">
								标题
							</div>
							<div class="right">
								<input class="input is-small" type="text" name="title" value="{{.Data.Title}}">
							</div>
						</li>
						<li>
							<div class="left">
								名称
							</div>
							<div class="right">
								<input class="input is-small" type="text" name="name" value="{{.Data.Name}}">
							</div>
						</li>
						<li>
							<div class="left">
								域名
							</div>
							<div class="right">
								<input class="input is-small" type="text" name="domain" value="{{.Data.Domain}}">
							</div>
						</li>
						<li>
							<div class="left">
								关键字
							</div>
							<div class="right">
								<input class="input is-small" type="text" name="keyword" value="{{.Data.Keyword}}">
							</div>
						</li>
						<li>
							<div class="left">
								站点描述
							</div>
							<div class="right">
								<input class="input is-small" type="text" name="description" value="{{.Data.Description}}">
							</div>
						</li>
						<li>
							<div class="left">
								Logo
							</div>
							<div class="right">
								<input class="input is-small" type="text" name="logo" value="{{.Data.Logo}}">
							</div>
						</li>
						<li>
							<div class="left">
								Favicon
							</div>
							<div class="right">
								<input class="input is-small" type="text" name="favicon" value="{{.Data.Favicon}}">
							</div>
						</li>
						<li>
							<div class="left">
								底部信息
							</div>
							<div class="right">
								<textarea class="textarea"   name="footer"  >{{.Data.Footer}}</textarea>
							</div>
						</li>
					
						<input type="hidden" name="sortNo" id="sortNo" value="1" />
						<input type="hidden" name="status" id="status" value="1" />
					</ul>

					<div class="field is-grouped" style="padding-left: 190px;">
						<div class="control">
							<button type="submit" class="button is-success is-small">提交</button>
						</div>
						<div class="control">
							<button type="reset" class="button is-info is-light is-small">重置</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</section>

<script>
	 //$("#status").val("{{.Data.Status}}")
	const form = document.getElementById('gpress-form')
	form.addEventListener('submit', async event => {
		event.preventDefault()

		const formData = new FormData(form)
		const jsonObject = {}
		for (const [key, value] of formData.entries()) {
			const fieldType = document.querySelector(key)
			jsonObject[key] = value
		}
		jsonObject.sortNo = jsonObject.sortNo-0
		jsonObject.status = jsonObject.status-0
		const response = await fetch(form.action, {
			method: form.method,
			body: JSON.stringify(jsonObject),
			headers: { 'Content-Type': 'application/json', }
		})
	
		let res = await response.json()
		if (res.statusCode == 1) {
			$.confirm({
				useBootstrap: false,
				boxWidth: '400px',
				title: '提示',
				content: '修改成功！',
				type: 'green',
				buttons: {
					'确定': function() {
						//window.location.href = '{{basePath}}admin/{{.UrlPathParam}}/list'
					}
				}
			})
		}
	})
</script>

{{template "admin/bodyend.html"}}
